﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Red.Core.UndoRedo
{
    /// <summary>
    /// Base user-induced action that can be undo-ed/redo-ed
    /// </summary>
    public interface IAction
    {
        /// <summary>
        ///  display name of the action (so it can be added to the "Undo" / "Redo" menus)
        /// </summary>
        string GetDisplayName();

        /// <summary>
        /// Execute action
        /// </summary>
        /// <param name="errorMessage">Possible error message.</param>
        /// <param name="history">Action history responsible for tracking this action.</param>
        /// <returns>True if the action was successful</returns>
        bool Do(ActionHistory history, ref string errorMessage);

        /// <summary>
        /// Revert execution of the action
        /// </summary>
        /// <param name="errorMessage">Possible error message</param>
        /// <param name="history">Action history responsible for tracking this action.</param>
        /// <returns>True if reverting the action was successful</returns>
        bool Undo(ActionHistory history, ref string errorMessage);
    }

}
